home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dirut / secret3.zip / GETPARM.INC < prev    next >
Text File  |  1992-10-23  |  2KB  |  71 lines

  1. ;GETPARM.INC
  2. ;Common subroutine for all XXSECRE2.ASM programs.
  3.  
  4. GetParm    PROC    NEAR            ;v1.2
  5.  
  6. ;First check the PSP to see if the user gave us a directory name
  7. ;on the command line.
  8.  
  9.     xor    cx,cx            ;clear MSB
  10.     mov    si,80H            ;PSP cmdline
  11.     cld                ;insure fwd
  12.  
  13.     lodsb                ;snarf length byte
  14.     mov    cl,al            ;into CL
  15.     jcxz    GetInput        ;no cmdline, query user
  16.  
  17. Got_Parm:
  18.     cmp    cl,7            ;max 7 chars
  19.     ja    Usage            ;illegal.
  20.     
  21.     inc    si            ;skip past separating space
  22.                     ;or input length (if buffered input)
  23.     mov    al,[si]            ;snarf first char
  24.     and    al,0D5H            ;uppercase
  25.     cmp    al,'0'            ;0..0, A..Z
  26.     jb    Usage            ;yep, give it and die
  27.     cmp    al,'Z'
  28.     ja    Usage            ;help and die
  29.  
  30. ;We have a command line entry.
  31.     dec    si            ;back up one
  32.     jmp    short GotName        ;make it untypeable, return
  33.  
  34. ;No cmdline input.  Prompt the user for it.
  35. GetInput:
  36.     mov    dx,offset msg180    ;'Enter name of subdirectory..'
  37.     mov    ah,9            ;display msg
  38.     int    21H
  39.     mov    si,80H            ;PSP cmdline
  40.     mov    byte ptr [si],7        ;max 7 chars input
  41.     mov    dx,si            ;input buffer=80H
  42.     mov    ah,0AH            ;get buffered input
  43.     int    21H
  44.     inc    si            ;SI -> 81H
  45.     mov    cl,[si]            ;user input length
  46.     jcxz    Usage            ;0 input: forget it
  47.  
  48. GotName:
  49.     mov    byte ptr [si],7FH    ;"untypeable" first char
  50. ;    inc    cx            ;inx name length for new 1st char
  51.     mov    dx,si            ;DS:DX -> dir name
  52.     add    si,cx            ;SI -> input's terminating CR
  53.     mov    [si],ch    ;0        ;AsciiZ the input
  54.     clc                ;insure CF clear (unneeded really)
  55.     ret                ;return DS:DX -> dirname
  56.                     ;CX = name length
  57.  
  58. Usage:
  59.     mov    dx,offset logo        ;'Usage..'
  60.     mov    al,-1            ;unlikely ERRORLEVEL
  61.     stc                ;set CF
  62.     ret
  63.  
  64. GetParm    ENDP
  65.  
  66. msg180    DB    'Enter name of subdirectory (7 characters maximum) - $'
  67.  
  68. msg1F0    DB    LF,'Error # '
  69. error1F9 db    '0.'            ;error digit            v1.1
  70.     db    CR,LF,'$'
  71.